﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using GoodsInvoicing.Views.ViewImpl;
using Spring.Context;
using Spring.Context.Support;

namespace GoodsInvoicing
{
    static class Program
    {
        //static log4net.ILog logger = log4net.LogManager.GetLogger("Logger");
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger("Logger");
        public static IApplicationContext applicationContext;

        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //InitializeProject();

            try
            {
                IApplicationContext applicationContext = ContextRegistry.GetContext();
                Application.Run(new LoginForm());
            }
            catch (Exception e)
            {
                log.Error(e.ToString());
                Console.WriteLine("...Error while initializing the application please contact thhe administrator...");

                //Abnormal program termination, killing the process
                Environment.Exit(Environment.ExitCode);    
            }
            
        }

        /// <summary>
        /// 初始化整个系统
        /// </summary>
        static void InitializeProject()
        {
            string[] locations = new string[] {
                    "app.config",
                    "assembly://GoodsInvoicing/GoodsInvoicing.Config/applicationContext-nhibernate.xml",
                    "assembly://GoodsInvoicing/GoodsInvoicing.Config/applicationContext-service.xml",
                };
            applicationContext = new XmlApplicationContext(locations);
        }
    }
}
